class Solution:
    def maxWidthRamp(self, A: list) -> int:
        indexes = [i for i in range(len(A))]
        indexes.sort(key=lambda x: A[x])
        m = len(A)
        res = 0
        for i in indexes:
            res = max(res, i - m)
            m = min(i, m)
        
        return res
